home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Apache 1.0 / src / http_config.h < prev    next >
Text File  |  1995-12-04  |  10KB  |  261 lines

  1.  
  2. /* ====================================================================
  3.  * Copyright (c) 1995 The Apache Group.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * 1. Redistributions of source code must retain the above copyright
  10.  *    notice, this list of conditions and the following disclaimer. 
  11.  *
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in
  14.  *    the documentation and/or other materials provided with the
  15.  *    distribution.
  16.  *
  17.  * 3. All advertising materials mentioning features or use of this
  18.  *    software must display the following acknowledgment:
  19.  *    "This product includes software developed by the Apache Group
  20.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  21.  *
  22.  * 4. The names "Apache Server" and "Apache Group" must not be used to
  23.  *    endorse or promote products derived from this software without
  24.  *    prior written permission.
  25.  *
  26.  * 5. Redistributions of any form whatsoever must retain the following
  27.  *    acknowledgment:
  28.  *    "This product includes software developed by the Apache Group
  29.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  30.  *
  31.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  32.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  34.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  35.  * IT'S CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  36.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  37.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  38.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  41.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  42.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  43.  * ====================================================================
  44.  *
  45.  * This software consists of voluntary contributions made by many
  46.  * individuals on behalf of the Apache Group and was originally based
  47.  * on public domain software written at the National Center for
  48.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  49.  * For more information on the Apache Group and the Apache HTTP server
  50.  * project, please see <http://www.apache.org/>.
  51.  *
  52.  */
  53.  
  54.  
  55. /*
  56.  * The central data structures around here...
  57.  */
  58.  
  59. /* Command dispatch structures... */
  60.  
  61. enum cmd_how {
  62.   RAW_ARGS,            /* cmd_func parses command line itself */
  63.   TAKE1,            /* one argument only */
  64.   TAKE2,            /* two arguments only */
  65.   ITERATE,            /* one argument, occuring multiple times
  66.                  * (e.g., IndexIgnore)
  67.                  */
  68.   ITERATE2,            /* two arguments, 2nd occurs multiple times
  69.                  * (e.g., AddIcon)
  70.                  */
  71.   FLAG,                /* One of 'On' or 'Off' */
  72.   NO_ARGS            /* No args at all, e.g. </Directory> */
  73. };
  74.  
  75. typedef struct command_struct {
  76.   char *name;            /* Name of this command */
  77.   char *(*func)();        /* Function invoked */
  78.   void *cmd_data;        /* Extra data, for functions which
  79.                  * implement multiple commands...
  80.                  */
  81.   int req_override;        /* What overrides need to be allowed to
  82.                  * enable this command.
  83.                  */
  84.   enum cmd_how args_how;    /* What the command expects as arguments */
  85.   
  86.   char *errmsg;            /* 'usage' message, in case of syntax errors */
  87. } command_rec;
  88.  
  89. /* Values for the req_override slot */
  90.  
  91. #define OR_NONE 0
  92. #define OR_LIMIT 1
  93. #define OR_OPTIONS 2
  94. #define OR_FILEINFO 4
  95. #define OR_AUTHCFG 8
  96. #define OR_INDEXES 16
  97. #define OR_UNSET 32
  98. #define ACCESS_CONF 64        /* command valid in access.conf */
  99. #define RSRC_CONF 128        /* command valid in srm.conf */
  100. #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
  101.  
  102. /*
  103.  * This structure is passed to a command which is being invoked,
  104.  * to carry a large variety of miscellaneous data which is all of
  105.  * use to *somebody*...
  106.  */
  107.  
  108. typedef struct {
  109.     void *info;            /* Argument to command from cmd_table */
  110.     int override;        /* Which allow-override bits are set */
  111.     int limited;        /* Which methods are <Limit>ed */
  112.     
  113.     char *config_file;        /* Filename cmd read from */
  114.     int config_line;        /* Line cmd read from */
  115.     FILE *infile;        /* fd for more lines (not currently used) */
  116.     
  117.     pool *pool;            /* Pool to allocate new storage in */
  118.     pool *temp_pool;        /* Pool for scratch memory; persists during
  119.                  * configuration, but wiped before the first
  120.                  * request is served...
  121.                  */
  122.     server_rec *server;        /* Server_rec being configured for */
  123.     char *path;            /* If configuring for a directory,
  124.                  * pathname of that directory.
  125.                  */
  126. } cmd_parms;
  127.  
  128. /* This structure records the existence of handlers in a module... */
  129.  
  130. typedef struct {
  131.     char *content_type;
  132.     int (*handler) ();
  133. } handler_rec;
  134.  
  135. /*
  136.  * Module structures.  Just about everything is dispatched through
  137.  * these, directly or indirectly (through the command and handler
  138.  * tables).
  139.  */
  140.  
  141. typedef struct module_struct {
  142.     int version;        /* API version, *not* module version;
  143.                  * check that module is compatible with this
  144.                  * version of the server.
  145.                  */
  146.     int module_index;        /* Index to this modules structures in
  147.                  * config vectors.
  148.                  */
  149.     struct module_struct *next;
  150.  
  151. #ifdef ULTRIX_BRAIN_DEATH
  152.     void (*init)();
  153.     void *(*create_dir_config)();
  154.     void *(*merge_dir_config)();
  155.     void *(*create_server_config)();
  156.     void *(*merge_server_config)();
  157. #else
  158.     void (*init)(server_rec *, pool *);
  159.     void *(*create_dir_config)(pool *p, char *dir);
  160.     void *(*merge_dir_config)(pool *p, void *base_conf, void *new_conf);
  161.     void *(*create_server_config)(pool *p, server_rec *s);
  162.     void *(*merge_server_config)(pool *p, void *base_conf, void *new_conf);
  163. #endif
  164.  
  165.     command_rec *cmds;
  166.     handler_rec *handlers;
  167.  
  168.     /* Hooks for getting into the middle of server ops...
  169.      *
  170.      * translate_handler --- translate URI to filename
  171.      * access_checker --- check access by host address, etc.   All of these
  172.      *                    run; if all decline, that's still OK.
  173.      * check_user_id --- get and validate user id from the HTTP request
  174.      * auth_checker --- see if the user (from check_user_id) is OK *here*.
  175.      *                  If all of *these* decline, the request is rejected
  176.      *                  (as a SERVER_ERROR, since the module which was
  177.      *                  supposed to handle this was configured wrong).
  178.      * type_checker --- Determine MIME type of the requested entity;
  179.      *                  sets content_type, _encoding and _language fields.
  180.      * logger --- log a transaction.  Not supported yet out of sheer
  181.      *            laziness on my part.
  182.      */
  183.     
  184.     int (*translate_handler)(request_rec *);
  185.     int (*check_user_id)(request_rec *);
  186.     int (*auth_checker)(request_rec *);
  187.     int (*access_checker)(request_rec *);
  188.     int (*type_checker)(request_rec *);
  189.     int (*fixer_upper)(request_rec *);
  190.     int (*logger)(request_rec *);
  191. } module;
  192.  
  193. /* Initializer for the first few module slots, which are only
  194.  * really set up once we start running.  Note that the first word
  195.  * is a version check; this should allow us to deal with changes to
  196.  * the API (the server can detect an old-format module, and either
  197.  * handle it back-compatibly, or at least signal an error).
  198.  */
  199.  
  200. #define MODULE_MAGIC_NUMBER 19950525
  201. #define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER, 0, NULL
  202.  
  203. /* Generic accessors for other modules to get at their own module-specific
  204.  * data
  205.  */
  206.  
  207. void *get_module_config (void *conf_vector, module *m);
  208. void set_module_config (void *conf_vector, module *m, void *val);     
  209.      
  210. /* Generic command handling function... */
  211.  
  212. char *set_string_slot (cmd_parms *, char *, char *);
  213.  
  214. /* For modules which need to read config files, open logs, etc. ...
  215.  * this returns the fname argument if it begins with '/'; otherwise
  216.  * it relativizes it wrt server_root.
  217.  */
  218.  
  219. char *server_root_relative (pool *p, char *fname);
  220.      
  221. /* Finally, the hook for dynamically loading modules in... */
  222.  
  223. void add_module (module *m);
  224.  
  225. #ifdef CORE_PRIVATE
  226.  
  227. /* For http_main.c... */
  228.  
  229. server_rec *read_config (pool *conf_pool, pool *temp_pool, char *config_name);
  230. void setup_prelinked_modules();
  231.  
  232. /* For http_request.c... */
  233.  
  234. void *create_request_config (pool *p);
  235. void *create_per_dir_config (pool *p);
  236. void *merge_per_dir_configs (pool *p, void *base, void *new);
  237.  
  238. /* For http_core.c... (<Directory> command and virtual hosts) */
  239.  
  240. int parse_htaccess(void **result, request_rec *r, int override,
  241.            char *path, char *file);
  242. char *srm_command_loop (cmd_parms *parms, void *config);
  243.  
  244. server_rec *init_virtual_host (pool *p, char *hostname);
  245. int is_virtual_server (server_rec *);
  246. void process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp);
  247.  
  248. /* Module-method dispatchers, also for http_request.c */
  249.  
  250. int translate_name (request_rec *);
  251. int directory_walk (request_rec *); /* check symlinks, get per-dir config */
  252. int check_access (request_rec *); /* check access on non-auth basis */
  253. int check_user_id (request_rec *); /* obtain valid username from client auth */
  254. int check_auth (request_rec *); /* check (validated) user is authorized here */
  255. int find_types (request_rec *);    /* identify MIME type */
  256. int run_fixups (request_rec *);    /* poke around for other metainfo, etc.... */
  257. int invoke_handler (request_rec *);     
  258. int log_transaction (request_rec *r);
  259.      
  260. #endif
  261.